<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增或编辑页</title>
    <style>
        body{
            background-color: bisque;
        }
        table{
            border-color: cadetblue;
            width: 200px;
            height: 250px;
            border-style: solid;
        }
    </style>
</head>
<body>
    <div id="content">
        <table id='form'>
            <tr><h2>添加博客或者修改</h2></tr>
            <tr hidden>
                <td><label for="">id</label></td>
                <td><input type="text" name="id"></td>
            </tr>
            <tr>
                <td><label for="">标题</label></td>
                <td><input type="text" name="title"></td>
            </tr>
            <tr>
                <td><label for="">摘要</label></td>
                <td><input type="text" name="digest"></td>
            </tr>
            <tr>
                <td><label for="">内容</label></td>
                <td><input type="text" name="details"></td>
            </tr>
            <tr>
                <td><label for="">分类</label></td>
                <td><input type="text" name="classify"></td>
            </tr>
            <tr>
                <td><label for="">作者</label></td>
                <td><input type="text" name="author"></td>
            </tr>
            <tr>
                <td><label for="">发表时间</label></td>
                <td><input type="text" name="ptime"></td>
            </tr>
            <tr>
                <td><input type="button" value="保存" onclick="save()"></td>
                <td><input type="button" value="取消" onclick="cancel()"></td>
            </tr>
        </table>
    </div>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./js/init.js"></script>
    <script src="./js/api.js"></script>
    <script>
        $(function(){
            let id=location.search.split('?')[1];
            getById(id).then(res=>{
                $('[name=id]').val(res['data'].id);
                $('[name=title]').val(res['data'].title);
                $('[name=digest]').val(res['data'].digest);
                $('[name=details]').val(res['data'].details);
                $('[name=classify]').val(res['data'].classify);
                $('[name=author]').val(res['data'].author);
            })
        })
    </script>
</body>
</html>